Imports System.Net
Imports System.IO
Imports System.Drawing

Partial Public Class TV
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim url As String = "http://www.atdhe.net/"
        Dim HttpWReq As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)

        Dim HttpWResp As HttpWebResponse = CType(HttpWReq.GetResponse(), HttpWebResponse)

        Dim strmReader As StreamReader = New StreamReader(HttpWResp.GetResponseStream())
        'Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(strmReader.BaseStream)


        Dim cachedHTML As String = strmReader.ReadToEnd()

       

        Dim rows As String()
        Dim stringSeparators() As String = {"<tr>"}
        rows = cachedHTML.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries)

        Dim tennisRows As New ArrayList

        For i As Integer = 0 To rows.Length - 1
            If rows(i).IndexOf("tennis") > 0 Then
                rows(i) = rows(i).Replace("newwindow('", "newwindow('http://www.atdhe.net/")
                rows(i) = rows(i).Replace("<a href=""", "<a href=""http://www.atdhe.net/")

                rows(i) = rows(i).Replace("live-tv", "http://www.atdhe.net/live-tv")
                rows(i) = rows(i).Replace(".html""", ".html"" target=_blank ")

                Dim cellsSeparator() As String = {"<td"}
                Dim cells As String() = rows(i).Split(cellsSeparator, StringSplitOptions.RemoveEmptyEntries)
                Dim finalRow As String = ""
                For j As Integer = 0 To cells.Length - 1
                    If j > 3 Then
                        finalRow += "<td" + cells(j)
                    End If
                Next

                'tennisRows.Add("<tr>" + rows(i) + Environment.NewLine)
                tennisRows.Add("<tr>" + finalRow + Environment.NewLine)
            End If
        Next


        Dim table As String = "<table border=0>" + Environment.NewLine
        For Each o As Object In tennisRows
            table += o.ToString()
        Next
        table += "</table>"

        Label1.Text = table
    End Sub

End Class